package com.qfedu.service.impl;

import com.qfedu.mapper.ProjectMapper;
import com.qfedu.model.Project;
import com.qfedu.page.PageResult;
import com.qfedu.page.QueryPageBean;
import com.qfedu.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author LiJH
 * @date 2023-02-08
 */
@Service
public class ProjectServiceImpl implements ProjectService {
    @Autowired
    private ProjectMapper projectMapper;
    @Override
    public PageResult findPage(QueryPageBean pageBean) {
        //返回pagereuslt
        PageResult page = new PageResult();
        //获取当前页和每页大小
        Integer currentPage = pageBean.getCurrentPage();
        Integer pageSize = pageBean.getPageSize();
        long count = projectMapper.count();
        page.setTotal(count);

        List<Project> pages = projectMapper.findPage((currentPage - 1) * pageSize, pageSize);
        page.setRows(pages);
        return page;
    }
}